﻿<%@ Page Title="" Language="C#" MasterPageFile="~/ProfessorPanel/ProfessorMP.Master" AutoEventWireup="true" CodeBehind="HealthyGrading.aspx.cs" Inherits="Fish_Atlantis.ProfessorPanel.HealthyGrading" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<style type="text/css">
table {
    border-top:2px solid #333333;
    border-bottom:2px solid #333333;
    border-collapse:collapse;
    padding: 20px;
    width: 100%
}
th {
    background:#333333;
    color:#f0f0f0;
    font-weight:bolder;
    padding:5px 10px
}
td {
    border-top: 1px solid #333333;
    padding: 3px 10px;
    color: Black;
}
textarea {
    resize: none;
    width:100%;
    height:60px;
}
.High {
    color:red;
}
.Med {
    color:orange;
}
.Low {
    color:green;
}
.None {
    color:gray;
}
</style>
<script type="text/javascript">
function radio_onchange(input) {
    var id = input.name.substr(9);
    var ec = document.getElementById("comment" + id);
    var ep = document.getElementById("publish" + id);
    if (input.value == "1") {
        ec.style.visibility = "hidden";
        ep.style.visibility = "hidden";
    }
    else {
        ec.style.visibility = "visible";
        ep.style.visibility = "visible";
    }
}
function filter_click() {
    var e = document.getElementById("action");
    e.value = "Filter";
    e.form.submit();
}
function save_click() {
    var e = document.getElementById("action");
    e.value = "Save";
    e.form.submit();
}
function publish_click() {
    es = document.getElementsByTagName("input");
    n = es.length;
    for (var i = 0; i < n; ++i) {
        e = es[i];
        if (e.id.length > 7 && e.id[0] == 'p' && e.id[1] == 'u' && e.checked && e.style.visibility != "hidden") {
            if (confirm("所选的风险信息一旦发布将无法撤回，如再有修改只能再次发布，确认继续？")) {
                var es = document.getElementsByTagName("input");
                n = es.length;
                var ea = document.getElementById("action");
                ea.value = "Publish";
                ea.form.submit();
                return;
            }
        }
    }
    alert("请先在表格最左列复选框中选择要发布的风险信息。");
}
function all_click(value) {
    es = document.getElementsByTagName("input");
    n = es.length;
    for (var i = 0; i < n; ++i) {
        e = es[i];
        if (e.id.length > 7 && e.id[0] == 'p' && e.id[1] == 'u' && e.style.visibility != "hidden") e.checked = value;
    }
}
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<div style="margin:2em">
<% if (Saved) { %>
    <table style="text-align:center; margin:0.5em 0em; padding:0; background:#ccffcc; border-color:#80cc80">
        <tr style="padding:0 0">
            <td style="padding:0.75em 0.2em; font-weight:normal; color:#006600">所有风险信息已于<% =Time.ToString("yyyy年M月d日hh:mm:ss") %>保存到数据库。</td>
        </tr>
    </table>
<% } %>
<% if (Published) { %>
    <table style="text-align:center; margin:0.5em 0em; padding:0; background:#ffddbb; border-color:#ff9966">
        <tr style="padding:0">
            <td style="padding:0.75em 0.2em; font-weight:normal; color:#800000"><% =PublishedCount %>条风险信息已于<% =Time.ToString("yyyy年M月d日hh:mm:ss") %>发布到相关供应商与客户部。</td>
        </tr>
    </table>
<% } %>
<input type="hidden" id="action" name="action"/>
<select style="min-width:100px; margin:5px" name="location">
  <option value="-" <% if (Location == "-") Response.Write("selected"); %>>全部地区</option>
<% foreach (var l in Locations)
   { %>
  <option value="<% =l %>" <% if (Location == l) Response.Write("selected"); %>><% =l %></option>
<% } %>
</select>
<select style="min-width:100px; margin:5px" name="category">
  <option value="-" <% if (Category == "-") Response.Write("selected"); %>>全部种类</option>
<% foreach (var c in Categories)
   { %>
  <option value="<% =c %>" <% if (Category == c) Response.Write("selected"); %>><% =c %></option>
<% } %>
</select>
<input style="margin:5px" type="button" value="  筛选  " onclick="filter_click()"/>
<h2>年度渔业风险信息</h2>
<table>
<tr>
<th style="text-align:left">渔业</th>
<% for (int m = 1; m <= Month; ++m)
   { %>
<th><% =MONTHS[m] %></th>
<% } %>
</tr>
<% foreach (var f in Fisheries)
   { %>
<tr style="text-align:center">
<td style="text-align:left; font-weight: bold"><% =f.Name %></td>
<% for (int m = 1; m < Month; ++m)
   {
       var risk = GetRisk(f, m);
       var i = risk.RiskLevel;
       var r = i == 3 ? "High" : i == 2 ? "Med" : i == 1 ? "Low" : "None"; %>
       <td class="<% =r %>" <% if (i > 1) Response.Write(string.Format(@"style = ""text-decoration:underline; cursor:pointer"", title=""{0}""", risk.Comment)); %>><% =r %></td>
<% } %>
<% {
       var risk = GetRisk(f, Month);
       var i = risk.RiskLevel;
       var r = i == 3 ? "High" : i == 2 ? "Med" : i == 1 ? "Low" : "None"; %>
       <td class="<% =r %>" <% if (i > 1) Response.Write(string.Format(@"style = ""font-weight:bold; text-decoration:underline; cursor:pointer"", title=""{0}""", risk.Comment)); else Response.Write(@"style=""font-weight:bold;"""); %>><% =r %></td>
<% } %>
</tr>
<% } %>
</table>

<h2>编辑当月（<% =MONTHS[Month] %>）渔业风险</h2>
<table>
<tr>
    <th style="width:1em"><input type="checkbox" onclick="all_click(this.checked)" title="发布选择"/></th>
    <th style="width:1px; text-align:left">渔业</th>
    <th style="width:80px; text-align:left;">风险等级</th>
    <th >评论</th>
</tr>
<% foreach (var e in Editing)
   {
       var id = e.Fishery.Id.ToString();
       var lv = e.RiskLevel;
       %>
<tr>
<td><input name="publish<% =id %>" id="publish<% =id %>" type="checkbox" title="发布选择" value="1" <% if (lv <= 1) Response.Write(@"style=""visibility:hidden"""); %>/></td>
<td nowrap="nowrap"><% =e.Fishery.Name %></td>
<td>
    <input name="risklevel<% =id %>" type="radio" value="3" onclick="radio_onchange(this)" <% if (lv == 3) Response.Write("checked"); %>/><span class="High">High</span><br/>
    <input name="risklevel<% =id %>" type="radio" value="2" onclick="radio_onchange(this)" <% if (lv == 2) Response.Write("checked"); %>/><span class="Med">Med</span><br/>
    <input name="risklevel<% =id %>" type="radio" value="1" onclick="radio_onchange(this)" <% if (lv == 1) Response.Write("checked"); %>/><span class="Low">Low</span>
</td>
<td><textarea id="comment<% =id %>" name="comment<% =id %>" <% if (lv <= 1) Response.Write(@"style=""visibility:hidden"""); %>><% =e.Comment %></textarea></td>
</tr>
<% } %>
</table>
<div style="text-align:right">
    <input style="margin:5px" type="button" value="  保存  " onclick="save_click()"/>
    <input style="margin:5px" type="button" value="  保存并发布  " onclick="publish_click()"/>
</div>
</div>
</asp:Content>
